#!/usr/bin/bash
workdir="$HOME/code"
codedir="$workdir/Microsoft VS Code"
codelink="https://az764295.vo.msecnd.net/stable/622cb03f7e070a9670c94bae1a45d78d7181fbd4/VSCode-win32-x64-1.53.2.zip"

mkdir -p "$workdir" "$codedir"
if [ $(uname -o) != Msys ] ; then
    die "Pleasa run this script in MSYS2"
fi
mkdir -p /mnt
mount "$(cygpath -w "$workdir")" /mnt
mkdir -p /mnt/etc /mnt/var/lib/pacman
cp -r pacman_config/{pacman.d,pacman.conf} /mnt/etc/
pacman --sysroot /mnt --noconfirm --needed -Syu mingw-w64-x86_64-{gcc,gdb,python,make,python-pylint}
wget "$codelink" -O "$workdir/code.zip"
cd "$codedir"
unzip "$workdir/code.zip"

